<template>
  <!-- 燃气报警流程对话框 -->
  <el-dialog v-model="visible" title="燃气报警流程" width="80%" align-center :before-close="handleClose">
    <div class="alarm-process-container">
      <el-image :src="alarmProcessImage" fit="contain" style="width: 100%; height: 70vh" :preview-src-list="[alarmProcessImage]" preview-teleported>
        <template #error>
          <div class="image-slot">
            <el-icon><Picture /></el-icon>
            <div>图片加载失败</div>
          </div>
        </template>
      </el-image>
    </div>
  </el-dialog>
</template>

<script setup lang="ts">
import alarmProcessImg from '@/assets/modeling/燃气报警流程.png';

interface Props {
  modelValue: boolean;
  imageSrc?: string;
}

interface Emits {
  (e: 'update:modelValue', value: boolean): void;
}

const props = withDefaults(defineProps<Props>(), {
  modelValue: false,
  imageSrc: alarmProcessImg
});

const emit = defineEmits<Emits>();

// 控制对话框显示状态
const visible = computed({
  get: () => props.modelValue,
  set: (value: boolean) => emit('update:modelValue', value)
});

// 图片路径
const alarmProcessImage = computed(() => props.imageSrc);

// 处理对话框关闭
const handleClose = () => {
  visible.value = false;
};
</script>

<style scoped lang="scss">
// 基础变量
$primary-bg: linear-gradient(270deg, rgba(9, 48, 111, 0.4) 0%, rgba(9, 48, 111, 0.8) 100%);
$title-font: PangMenZhengDao;

// 燃气报警流程对话框样式
.alarm-process-container {
  display: flex;
  justify-content: center;
  align-items: center;

  .image-slot {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    color: #909399;
    font-size: 14px;
    gap: 8px;
  }
}

:deep(.el-dialog) {
  .el-dialog__header {
    background: $primary-bg;
    color: white;
    padding: 15px 20px;
    .el-dialog__title {
      font-family: $title-font;
      font-size: 18px;
    }
  }

  .el-dialog__body {
    padding: 20px;
    background: rgba(9, 48, 111, 0.1);
  }
}
</style>
